[Hibernate] Problem with saveOrUpdate()
Posted
by kunkanwan
on Stack Overflow
See other posts from Stack Overflow
or by kunkanwan
Published on 2010-05-18T13:05:55Z
Indexed on
2010/05/18
13:10 UTC
Read the original article
Hit count: 243
Hi, I've problem with Hibernate.
I have a class User
class User {
int id;
String name;
}
where id
is native generator in User.hbm.xml , and name
is primary-key in DB.
In my database , I saved some information about Users.
Than, I want to connect with this information about User.
For example in my DB i have row INSERT INTO User VALUES ('Bill');
Main.java
User bill = new User(); bill.setName("Bill"); session.saveOrUpdate(bill);
This code always trying insert bill
to database , rather than update when row about Bill exists in DB...
Could you help me ?
Thank you for advance.
© Stack Overflow or respective owner